unit f_give;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls;

type
  Tfgive = class(TForm)
    cb1: TComboBox;
    hme: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure FormActivate(Sender: TObject);
    procedure cb1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fgive: Tfgive;
  gindex:array[1..10] of byte;
  gcount:integer;

implementation

{$R *.DFM}

uses struct,hstruct,cldata,clunit1;

procedure Tfgive.FormActivate(Sender: TObject);
var
 i:integer;
begin
 cb1.items.clear;
 gcount:=0;
 for i:=1 to 10 do if hpa.exist(i) and (i<>usnum) then begin
  gcount:=gcount+1;
  gindex[gcount]:=i;
  cb1.Items.add(hrac.getname(i));
 end;
 if gcount>0 then cb1.itemindex:=0;
end;

procedure Tfgive.cb1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
 col:Tcolor;
 r:Trect;
begin
 cb1.canvas.brush.color:=clwhite;
 r.left:=rect.left-1;
 r.top:=rect.top-1;
 r.Top:=rect.right+1;
 r.Bottom:=rect.bottom+1;
 cb1.canvas.fillrect(rect);
 if odselected in state then begin cb1.canvas.brush.color:=clnavy;
  cb1.canvas.fillrect(rect); col:=clwhite; end else col:=clblack;
 mainwin.fl.draw(cb1.canvas,rect.left+1,rect.top+2,gindex[index+1]);
 cb1.canvas.Font.color:=col;
 cb1.canvas.textout(rect.left+12,rect.top,cb1.items[index]);
end;

procedure Tfgive.SpeedButton1Click(Sender: TObject);
begin
 giverace:=gindex[cb1.itemindex+1];
 givemoney:=strtoint(hme.text);
 close;
end;

procedure Tfgive.SpeedButton2Click(Sender: TObject);
begin
 close;
end;

end.
